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

Why does my script only work in play solo but when I play with roblox player?

Here's my script v v v It always work when I play solo but NEVER when I try playing with roblox player. :/ It's suppose to replace only the shirt of the player when he/she touches the block...

Platform = script.Parent

Platform.Touched:connect(function(hit)
	local h = hit.Parent
	if h.ClassName ~= "Model" then
		return nil
	elseif h.ClassName == "Model" then
		h.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=65387140"
	end
end)

1 comment

0

If possible, do give me a fixed version of the script :/

2 answers

Your method of checking to see if a Player hit your 'Platform' is easily broken. As well, the character may or may not have a Shirt object when you try to access it, you'll have to add one in if they don't. Try this code instead:

Platform = script.Parent

Platform.Touched:connect(function(hit)
    local h = hit.Parent
	if not Game.Players:GetPlayerFromCharacter(h) then return end
	if not h.Shirt then Instance.new("Shirt", h).Name = "Shirt" end
    h.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=65387140"
end)

You took it from Free Modules I guess. What does output shows you?

1 comment

0

Please do not submit an answer that is just a comment of the OP's question. There is a comment section just for that. (I know you can't use it yet, so just hold out until you get enough reputation that you can.)

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