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

I'm trying to change a value when a player touches a part?

Asked by 4 years ago
Edited 4 years ago

Well i made a tool that has a function which fires an animation and should make a screen gui visible when the player is touching a certain part i tried to insert a boolvalue in the server storage it works but i always get a warning that value isn't a valid member of server storage? (The print touched works) This is a normal script

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        print("Touched")
        game.ServerStorage.Value = true
    end
end)

script.Parent.TouchEnded:Connect(function(hitend)
    if hitend.Parent:FindFirstChild("Humanoid") then
        print("Touch ended")
        game.ServerStorage.Value = false
    end
end)
0
Is this in a LocalScript or Script? AntiWorldliness 868 — 4y
0
If it’s local, you can’t access the serverstorage DarkDanny04 407 — 4y
0
Is there something in serverstorage that is named Value? Aztralzz 169 — 4y
0
You need to first reference what the bool value is called like this: game.ServerStorage.whateveryounamedyourvalue.Value ProjectInfiniti 192 — 4y

1 answer

Log in to vote
1
Answered by
Aztralzz 169
4 years ago

Maybe try this. The BoolValue can be put into a variable, so you don't have trouble.

local Value = game.ServerStorage.YourBoolValueName.Value
script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            print("Touched")
            Value = true
        end
    end)

    script.Parent.TouchEnded:Connect(function(hitend)
        if hitend.Parent:FindFirstChild("Humanoid") then
            print("Touch ended")
            Value = false
        end
    end)

I didn't test this. If it doesn't work, I'm happy to keep helping. Good Luck on whatever you are making!

Ad

Answer this question