This is a script that was made to communicate with a local part and change the local part's properties when touched by a player, however in testing, it does not work and shows this error in the output:
14:04:17.509 - Value is not a valid member of Model
14:04:17.510 - Script 'Workspace.Part.Script', Line 3
14:04:17.510 - Stack End
This is the script that I am using in the block that the player touches:
script.Parent.Touched:connect(function(hit) if game.Players:FindFirstChild(hit.Parent.Name) then hit.Parent.Value.Value = true end end)
and this is the localscript that I am using to spawn the localpart, and change its properties when the player touches the brick that the script above is in:
local character = game.Players.LocalPlayer.Character local container = Workspace:FindFirstChild("LocalBin") if not container then container = Instance.new("Camera") container.Name = "LocalBin" container.Parent = Workspace end local platform = Instance.new("Part") platform.CFrame = platform.CFrame * CFrame.new(23, 3.5, -119.5) platform.Anchored = true platform.Size = Vector3.new(2, 7, 7) platform.LeftSurface = "SmoothNoOutlines" platform.TopSurface = "SmoothNoOutlines" platform.Material = "Slate" local StoneSound = Instance.new("Sound") StoneSound.Name = "Slateskin" StoneSound.SoundId = "rbxassetid://270070244" StoneSound.Volume = 1 StoneSound.Parent = game.Workspace.soundpart StoneSound.Looped = false StoneSound.Pitch = 0.8 platform.Parent = container local p = Instance.new("BoolValue",character) p.Changed:connect(function() game.Workspace.soundpart.Slateskin:Play() for i=3.5, -3.8, -0.083 do wait(0.01) container.Part.CFrame = CFrame.new(23, i, -119.5) end end)
There is nothing wrong with the second script, I am just using it as a reference just so that it may help, the only errors I am getting is from the first script that I mentioned at the beginning
make sure that the value object is put in the player everytime that there character spawns thats the best advice that i have for you
What ProfessorSev meant is that you should probably spawn in the bin, parts, sounds, values, EVERY time the player spawns. Heres a function you can use.
game:GetService("Players").PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(Character) --Place the creation of the bin for the local parts, actual parts, sounds, values, here. --It will be run every time the player respawns, because local parts are removed upon death. end) end)