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

using a local variable in a formula?

How do you access "touchedman" in a formula

function ontouch(hit)
    local touchedman = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
    if player then
        
	game.Workspace.touchedman.Folder.BoolValue.Value = true

    end
end

script.Parent.Touched:Connect(ontouch)

2 answers

✓ Accepted answer
game.Workspace[touchedman.Name].Folder.BoolValue.Value = true

or you could use touchedman.Character (if its their character)

touchedman.Character.Folder.BoolValue.Value = true

1 comment

0

i think this is what your trying to do because of the line "game.Workspace.touchedman.Folder.BoolValue.Value = true"

Not sure if I understand your question correctly but:

script.Parent.Touched:Connect(function(obj)
	workspace[obj.Parent].Folder.BoolValue.Value = true -- Goes into workspace and tries to find the player who touched the object
end)

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