I'm trying to make a level door system, I have the database all set up and working but my door is not working with the error in the title. Can anyone give me a hand? Thanks.
local DataStore2 = require(1936396537) local player = game.Players.LocalPlayer.UserId script.Parent.Touched:Connect(function() local levelStore = DataStore2("Level", player) if levelStore <= 1 then script.Parent.CanCollide = false end end) script.Parent.TouchEnded:Connect(function() local levelStore = DataStore2("Level", player) if levelStore <= 1 then script.Parent.CanCollide = true end end)
you need to hook up the player from the colliding part ie:
-- mockup DataStore NOT NEEDED! local DataStore2 = (function(Group, player) -- require(1936396537) local DS = { ["Level"] = { ["TGazza"] = 0 } } if(DS[Group] ~= nil) then if(DS[Group][player] ~= nil) then return DS[Group][player] end end return math.huge -- Omg it's Huge! end) local Players = game:GetService("Players") script.Parent.Touched:Connect(function(bit) local player = Players:GetPlayerFromCharacter(bit.Parent) if(player == nil) then return end local levelStore = DataStore2("Level", player.Name) if levelStore <= 1 then script.Parent.CanCollide = false end end) script.Parent.TouchEnded:Connect(function(bit) local player = Players:GetPlayerFromCharacter(bit.Parent) if(player == nil) then return end local levelStore = DataStore2("Level", player.Name) if levelStore <= 1 then script.Parent.CanCollide = true end end)
hope this helps! :)