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

Why won't this detection script work?

local part = script.Parent

game.Players.PlayerAdded:connect(function(plr)
part.Touched:connect(function(hit)
	if hit.Name == "auto" .. plr.Name then
		if game.Lighting.SecretsFolder:FindFirstChild("shrek") then
		local shrek = game.Lighting.SecretsFolder.shrek
		shrek.Parent = game.Workspace
		shrek.Position = part.Position - Vector3.new(3.4, 0, 0)
		else
			local p = game.Lighting.SecretsFolder.poo:Clone()
			p.Parent = game.Workspace
			p.Position = part.Position + Vector3.new(3.4, 0, 0)
		end
	end
end)
end)

This works on studio, but no in-game? Why? Thanks for help!

1 answer

I'm not sure why is there hit.Name == "auto"..plr.Name. I assume you wanted make part.Name == "auto".. plr.Name.

local part = script.Parent

game.Players.PlayerAdded:connect(function(plr)
part.Touched:connect(function(hit)
    if part.Name == "auto" .. plr.Name and game.Players:FindFirstChild(plr.Name) ~= nil then --check if player Exist. Seems like name of script.Parent is adjusted by script. If you name it 'autoPlayer1' in studio and did not rename it to 'autohappyturk4' when you played the game. It could not have worked because it's name was autoPlayer1 not autohappyturk4. However I might be wrong. This script works if script.Parent name would be autohappyturk4
        if game.Lighting.SecretsFolder:FindFirstChild("shrek") then
            local shrek = game.Lighting.SecretsFolder.shrek
            shrek.Parent = game.Workspace
            shrek.Position = part.Position - Vector3.new(3.4, 0, 0)
        else
            local p = game.Lighting.SecretsFolder.poo:Clone()
            p.Parent = game.Workspace
            p.Position = part.Position + Vector3.new(3.4, 0, 0)
        end
    end
end)
end)

7 comments

0

thats how the script works, thats what the bullet is called....

0

Well this script works not only in studio

0

it does

0

So did I answer your question?

0

no!?!?! you just came here and told me what i was doing was wrong....thats how the SCRIPT WORKS

0

Well you wanted it to works in game. It does now. You need anything else?

0

it does NOW? get out kid

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