So what I have is I want to change a boolvalue in a player, I've made a script to put value in the player and this is that script.
game.Players.PlayerAdded:Connect(function(player) local boolValue = Instance.new("BoolValue", player) boolValue.Name = "InPod" boolValue.Value = false end)
Then of course it appears in the player but I cant for the life of it change the value I have this script but I can't get it to work!
function onTouched(part) local v = part.Parent:findFirstChild("InPod") if v ~= false then v.Value = true end end script.Parent.Touched:connect(onTouched)
Also I'm pretty new to scripting and this is my first proper game so please put into detail thanks :).
EDIT: I thought I forgot something when the value is true it should not teleport the player to another game which I need and when the value is false, it should teleport the player to a different game, also heres what I have thanks to help by botw_legend I have this.
script.Parent.Touched:Connect(function(part) if part.Parent:FindFirstChild("Humanoid") then local bool = part.Parent.InPod bool.Value = true end end) game.Players.PlayerAdded:Connect(function(plr) local char = game.Workspace:WaitForChild(plr.Name) local bool = Instance.new("BoolValue",char) bool.Name = "InPod" bool.Value = false end)
so i tested this and it works so in the part you want it to touch add a script and put in this code:
local TeleportService = game:GetService("TeleportService") script.Parent.Touched:Connect(function(part) if part.Parent:FindFirstChild("Humanoid") and part.Parent:FindFirstChild("InPod") then local player = game.Players:FindFirstChild(part.Parent.Name) local bool = part.Parent.InPod bool.Value = true TeleportService:Teleport(numbers, player)--change numbers end end) game.Players.PlayerAdded:Connect(function(plr) local char = game.Workspace:WaitForChild(plr.Name) local bool = Instance.new("BoolValue",char) bool.Name = "InPod" bool.Value = false end)
placeid is the number in the link when viewing your game a picture would look like this
it will put in a bool in the character and if you step or touch the part it will turn it from false to true i hope this helped!