I've made a script where if you touch a brick it changes color, but only on the client's screen. I finally got it to work, but then there's this error in the title ^
The script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local completeWorldEvent = ReplicatedStorage:WaitForChild("CompleteWorldEvent") --RemoteEvent
local endPart1 = game.Workspace.World1.EndPart --1st part
local endPart2 = game.Workspace.World2.EndPart --2nd part
local function checkEndPart1(partTouching) --1st part script
if partTouching.Parent:FindFirstChild("Humanoid") then --line that makes the error
local player = game.Players:GetPlayerFromCharacter(partTouching.Parent)
if endPart1.Color == Color3.fromRGB(255,255,0) then
endPart1.Color = Color3.fromRGB(0,255,0)
end
end
end
game.Workspace.World1.EndPart.Touched:Connect(checkEndPart1)
local function checkEndPart2(partTouching) --2nd part script
if partTouching.Parent:FindFirstChild("Humanoid") then --similar line, also makes error
local player = game.Players:GetPlayerFromCharacter(partTouching.Parent)
if endPart2.Color == Color3.fromRGB(255,255,0) then
endPart2.Color = Color3.fromRGB(0,255,0)
end
end
end
game.Workspace.World2.EndPart.Touched:Connect(checkEndPart2)
completeWorldEvent.OnClientEvent:Connect(checkEndPart1)
completeWorldEvent.OnClientEvent:Connect(checkEndPart2)
I'm a noob at scripting so I can't figure out the issue, can someone help please? <3

1 comment
I'll check back in like 2-3 hours