Every time I post the text through to the server so it can be replicated to the workspace it, it always an error relating to '(String Expected, Got Object)'
The script that fires is something like this (In Player Scripts):
while true do for i,v in pairs(script.Parent.Parent:WaitForChild("PlayerGui"):GetChildren())do if v.Name == "BoardUI" then script.Parent.Parent:WaitForChild("PlayerGui").BoardUI.BUI.Enter.MouseButton1Click:Connect(function() local player = game.Players.LocalPlayer local desc = script.Parent.Parent.PlayerGui.BoardUI.BUI.Desc.Text game.ReplicatedStorage.BoardChange:FireServer(player,desc) end) else print("Not A Child") end end wait(10) end
The recieving script gives the error (In Server Script Service):
game.ReplicatedStorage.BoardChange.OnServerEvent:Connect(function(player,desc) for i,v in pairs(game.Workspace:GetChildren())do if v.Name == "WhiteBoardR" then if v.CurrentEdit == player.Name then v.Board.SurfaceGui.Desc.Text = desc end end end end)
I am not sure what this is caused by and have spent weeks trying to look on other peoples answers to try to find a more clearly demonstrated outlook.
Any help is appreciated! :D
When you call :FireServer()
you don't need to pass the player, this is automatically done by Roblox. Simply don't send the player. Also use a variable if you're going to use something a lot. Using script.Parent.Parent
just to get the player each time is unacceptable.
local client = game:GetService("Players").LocalPlayer local playerGui = client:WaitForChild("PlayerGui") while true do for _, v in ipairs(playerGui:GetChildren())do if v.Name == "BoardUI" then v.BUI.Enter.Activated:Connect(function() local desc = v.BUI.Desc.Text game.ReplicatedStorage.BoardChange:FireServer(desc) end) else print("Not A Child") end end wait(10) end