Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this script work in studio but not in game?

The script is supposed to change the player's shirt and pants when they enter the game. It works perfectly in studio solo mode, but not when I actually go in game. Filtering enabled is on as well.

wait(2)
if script.Parent.Parent.TeamColor == BrickColor.new("Bright red") then
if workspace:FindFirstChild(script.Parent.Parent.Name):FindFirstChild("Shirt") == nil then
if workspace:FindFirstChild(script.Parent.Parent.Name):FindFirstChild("Pants") ~= nil then
workspace:FindFirstChild(script.Parent.Parent.Name).Pants:remove()
a = Instance.new("Shirt")
a.ShirtTemplate = ("http://www.roblox.com/asset/?id=356273812")
a.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
b = Instance.new("Pants")
b.PantsTemplate = ("http://www.roblox.com/asset/?id=356262036")
b.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
else
a = Instance.new("Shirt")
a.ShirtTemplate = ("http://www.roblox.com/asset/?id=356273812")
a.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
b = Instance.new("Pants")
b.PantsTemplate = ("http://www.roblox.com/asset/?id=356262036")
b.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
end
else 
if workspace:FindFirstChild(script.Parent.Parent.Name):FindFirstChild("Pants") ~= nil then
workspace:FindFirstChild(script.Parent.Parent.Name).Shirt:remove()
workspace:FindFirstChild(script.Parent.Parent.Name).Pants:remove()
a = Instance.new("Shirt")
a.ShirtTemplate = ("http://www.roblox.com/asset/?id=356273812")
a.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
b = Instance.new("Pants")
b.PantsTemplate = ("http://www.roblox.com/asset/?id=356262036")
b.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
else
workspace:FindFirstChild(script.Parent.Parent.Name).Shirt:remove()
a = Instance.new("Shirt")
a.ShirtTemplate = ("http://www.roblox.com/asset/?id=356273812")
a.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
b = Instance.new("Pants")
b.PantsTemplate = ("http://www.roblox.com/asset/?id=356262036")
b.Parent = workspace:FindFirstChild(script.Parent.Parent.Name)
end
end
end

1 comment

0

I have the same problem with these GUI scripts that I have (posted in another question). In need of help.

1 answer

✓ Accepted answer

You are currently running with FilteringEnabled set to true, as such you must use RemoteEvent

First, you must make a script in the ServerScriptService, and put this into the script:

game.Players.PlayerAdded:connect(function(player)
	local createEvent = Instance.new("RemoteEvent")
	createEvent.Parent = player
	createEvent.Name = "cEvent"
	player.CharacterAdded:connect(function(Character)
		wait(5)
		createEvent:FireClient(player)
	end)
end)

This will now connect to the players client and tell it to do something.

Next, you must receive the RemoteEvent using a LocalScript We will use this line of code inside the players StarterGui in a LocalScript:

local player = game.Players.LocalPlayer
local character = player.Character

player:WaitForChild("cEvent").OnClientEvent:connect(function()
	if player.TeamColor == game.Teams["Bright red Team"].TeamColor then --[[ This will get the teamname, instead of the color... so you will need to change 'Bright red Team' to the team you wish to have. ]]
		if character:FindFirstChild("Shirt") then
			character.Shirt:Destroy()
		end
		if character:FindFirstChild("Pants") then
			character.Pants:Destroy()
		end
		Instance.new("Shirt",character).ShirtTemplate = "http://www.roblox.com/asset/?id=356273812"
		Instance.new("Pants",character).PantsTemplate = "http://www.roblox.com/asset/?id=356262036"
	end
end)

Help can be found on this roblox wiki page:

http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial

If you still cannot figure out what to do, check this roblox place... It will be up for a little while:

https://www.roblox.com/games/407499593/Scripting-Helpers-answer

If you need further help, contact me on roblox:

https://www.roblox.com/messages/compose?recipientId=18982229

~ Taryo

4 comments

0

How do you know for sure he is running a game with filtering enabled set to true?\

0

When he asked his question he said: "Filtering enabled is on as well.", in the first paragraph of his statement. FilteringEnabled being on means that FilteringEnabled is set to true.

0

Thank you, this helped a lot! It finally works now!

0

You're welcome! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.