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

Why does this script appear to be working in Studio but not Roblox Player?

Asked by 3 years ago
Edited 3 years ago
local Gate = game.Workspace.OwOMachine3000.Tunnel.Section3["3rdScanner"].LaserGate
local players = game:GetService("Players")

Gate.Touched:Connect(function(hit)
    if hit and hit.Parent:FindFirstChild("Humanoid") then
        local Char = hit.parent --this contains all the character limbs
        local Name = Char.Name
        local head = Char.Head
        local hair = Char["Brown Hair"]

        local plr = players[Name]
        print("plr")

        wait(5)

        for i,v in pairs(Char:GetChildren()) do
            if v:IsA("MeshPart") then

                v.Color = Color3.new(1, 1, 1)
                head.Color = Color3.new(1, 1, 1)
                hair.Parent = game.ServerStorage

            end
        end
    end 
end)

This is a script I've got that is supposed to change the colour of all the body parts and remove the hair when the Client touches a brick, it works perfectly in Studio and in a Local Server but when I play the game on Roblox it only changes the head colour and nothing else, and the hair stays on the character, does anyone know why this is?

0
Is it a local script? ZIRFAL3 17 — 3y
0
yeah WeaponisedPenguins 97 — 3y
0
there's the problem ZIRFAL3 17 — 3y
0
okay ill try a serverscript WeaponisedPenguins 97 — 3y
View all comments (3 more)
0
Use a Remote event that fires a server event, and with a normal script, you do all the changes you want the rest of the players to see. ZIRFAL3 17 — 3y
0
Use Event:FireServer(v) ZIRFAL3 17 — 3y
0
wait what? so I need to make a serverscript that fires a remote event when the part is touched, then make a serverscript that has all of the above code in? WeaponisedPenguins 97 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago

Put this script into the LaserGate, You used a LocalScript on something that should be Serversided.

local Gate = script.Parent
local players = game:GetService("Players")
local SS = game:GetService("ServerStorage")

Gate.Touched:Connect(function(hit)
    if hit and hit.Parent:FindFirstChild("Humanoid") then
        local Char = hit.parent --this contains all the character limbs
        local Name = Char.Name
        local head = Char.Head
        local hair = Char["Brown Hair"]

        local plr = players[Name]
        print("plr")

        wait(5)

        for i,v in pairs(Char:GetChildren()) do
            if v:IsA("MeshPart") then

                v.Color = Color3.fromRGB(255,255,255)
                head.Color = Color3.fromRGB(255,255,255)
                hair.Parent = SS

            end
        end
    end 
end)
Ad
Log in to vote
0
Answered by 3 years ago
  1. You can get player with players:GetPlayerFromCharacter(Char)
  2. Not every player has brown hair unless you give it to them first(I assume you do)
  3. Change to:
for i,v in pairs(Char:GetChildren()) do
            if v:IsA("Part") then
                v.Color = Color3.new(1, 1, 1)
                hair.Parent = game.ServerStorage
            end
        end
  1. I don't remember if Color3 works on parts but if it doesn't then use BrickColor.new
0
had to use brickcolor, but instead of working perfectly fine in studip, its only making the head white and removing the hair, and now in roblox player its doing nothing WeaponisedPenguins 97 — 3y
0
Color3 does work on parts, BrickColor is just a simplified version of it that has Presets. (I suggest using Color3.fromRGB() instead of BrickColor) AwesomeGamer2223 105 — 3y

Answer this question