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

This event is designed to colour parts inside a model that's been placed inside the character. It does not work in test or player mode. I suspect the problem may be passing the variable 'data' through but I don't know how else to do it. Many thanks!

Client

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

Server

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)
                end
            end
        end
    end
end)

0
You are not even setting the color of the BrickColor. You are setting the BrickColor to "script.Parent" witch is "data". FiredDusk 1466 — 7y
0
Instead of having it as "local data = script.Parent", make it as "local data = "Bright yellow" or some other color... FiredDusk 1466 — 7y
0
data is being sent over as script.Parent.Name in line 5 of the client script Samstergizmo 28 — 7y
0
The parent of the script is of course, named after the colour It would be colouring with... Samstergizmo 28 — 7y

Answer this question