制作服装GUI

我正在尝试制作一个GUI(在roblox studio中),当角色点击按钮时,他或她将获得一套衣服。

ServerScriptService 代码

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "UniformGiveEvent"
local Shirt = "rbxassetid://182645836"
local Pants = "rbxassetid://824967650"

function GiveUni(plr)
    local character = plr.Character
    local shirt = character.Shirt
    local pants = character.Pants
    shirt.ShirtTemplate = Shirt
    pants.PantsTemplate = Pants
end

Event.OnServerEvent:Connect(GiveUni)

GUI本地脚本

local button = script.Parent.GiveUniform
local debounce = true
local UniEvent = game.ReplicatedStorage:WaitForChild("UnifromGiveEvent")

button.MouseButton1Click:Connect(function()
    if debounce then
         debounce = false
         UniEvent:FireServer()
    end
 end)
点赞
用户9024298
用户9024298

当你启动服务器时,你没有将玩家发送到服务器。你没有提供函数(GiveUni)所需的参数(一个玩家)。

为了解决这个问题,只需要改变这两行;

button.MouseButton1Click:Connect(function()

button.MouseButton1Click:Connect(function(player)

UniEvent:FireServer()

UniEvent:FireServer(player)
2019-02-23 13:35:13
用户11121446
用户11121446
`Event.Name = "UniformGiveEvent"`
`local UniEvent = game.ReplicatedStorage:WaitForChild("UnifromGiveEvent")`

至少,你的事件名称和等待子项的名称有一个简单的拼写错误。(Unif **or** mGiveEvent/Unif **ro** mGiveEvent)
2019-02-26 19:49:57