Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Every Time I Pass 'Text' or 'Values' Through Filtering Enabled, Why Does it Sense As An Object?

Asked by 5 years ago

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

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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

Don't forget to accept if this helps

0
I don't think you even need a for loop since you can put it in the BUI.Enter and avoid this. User#24403 69 — 5y
0
Thanks, this helped get a better understanding of how I need to structure everything. Nikkasfied 43 — 5y
Ad

Answer this question