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

Why won't this detection script work?

Asked by 8 years ago
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

Log in to vote
0
Answered by
deris88 146
8 years ago
Edited 8 years ago

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)

0
thats how the script works, thats what the bullet is called.... happyturk4 33 — 8y
0
Well this script works not only in studio deris88 146 — 8y
0
it does happyturk4 33 — 8y
0
So did I answer your question? deris88 146 — 8y
View all comments (3 more)
0
no!?!?! you just came here and told me what i was doing was wrong....thats how the SCRIPT WORKS happyturk4 33 — 8y
0
Well you wanted it to works in game. It does now. You need anything else? deris88 146 — 8y
0
it does NOW? get out kid happyturk4 33 — 8y
Ad

Answer this question