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

Am I using this RemoteEvent correctly?

Asked by 7 years ago
Edited 7 years ago

This script is a colouring script, the client is inside a Gui button that can be selected, named after the appropriate colour. The server script is inside ServerScriptStorage. This script is not working in test mode OR in game, I have a part selected and named 'Target' which is a string value, this is the part that needs to be coloured.

This is the client side script;

local player = game.Players.LocalPlayer
local data = script.Parent
local event = game.ReplicatedStorage:WaitForChild("ColouringEvent")
script.Parent.MouseButton1Click:Connect(function()
    print('ok')
    event:FireServer(data.Name)
end)

This is the Server side script;

local event = game.ReplicatedStorage:WaitForChild("ColouringEvent")
event.OnServerEvent:Connect(function(player, colour)
    local Target = game.ReplicatedStorage.Target
    local character = player.CharacterAdded:wait()
    local Get = character:GetChildren()
    for i = 1, #Get do
        if Get[i].ClassName == "Model" then
            local Gget = Get[i]:GetChildren()
            for i = 1, #Gget do
                if Gget[i].Name == Target.Value then
                Gget[i].BrickColor = BrickColor.new(colour)
                print('Check if Coloured')
                end
            end
        end
    end
end)
0
Seems fine. I may have missed something tho AstrealDev 728 — 7y
0
I mean, could it be an issue with the transferring data? 'data.Name --> colour' Samstergizmo 28 — 7y

Answer this question