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

Why doesn't this RemoteEvent replicate properly?

Asked by 5 years ago

I have a RemoteEvent (Client to Server) that is combined with UserInputService, that makes it where, when the player presses a certain key, their arm changes color and when they punch, they do a bit more damage. I managed to get all of that working, but I noticed that if the key is pressed before any other players are in the game, when a player joins they don't see the change in color at all. How would I make it where the change in color also replicates to new players as they join?

0
here's the thing, we can't help you without code unless it is a really basic issue theking48989987 2147 — 5y

1 answer

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

Well, since we can't see your code, I'll just give an example of what the scripts should look like (in relation to the color issue only)

Local Script

local remote = game.ReplicatedStorage.RemoteEvent

game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.T then
        remote:FireServer()
    end
end)

Server Script

local remote = game.ReplicatedStorage.RemoteEvent

remote.OnServerEvent:Connect(function(player)
    local character = workspace:FindFirstChild(player.Name)
    local armcolor = character:FindFirstChild("Body Colors")
    if armcolor ~= nil then
        armcolor.RightArmColor3 = Color3.fromRGB(0, 0, 0)
    else
        character["Right Arm"].Color = Color3.fromRGB(0, 0, 0)
    end
end)

Anything that is altered on the Server will be replicated for all Clients to see, so my only assumption can be that the color change is occurring on the Client's LocalScript instead of within the Server Script.

For this example, I am using the key "T" to activate the event, which will change the player's Right Arm Color using a Remote Event named "RemoteEvent" within Replicated Storage

0
I think I may have just found the issue looking at this, and if it's solved I'll come back and accept your answer. KardashevScale 110 — 5y
1
here's some advice: don't answer questions that have no code included DeceptiveCaster 3761 — 5y
Ad

Answer this question