How can I fix this script to run when touched?
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:
1 | script.Parent.Touched:connect( function (hit) |
2 | if game.Players:FindFirstChild(hit.Parent.Name) then |
3 | hit.Parent.Value.Value = true |
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:
01 | local character = game.Players.LocalPlayer.Character |
02 | local container = Workspace:FindFirstChild( "LocalBin" ) |
04 | container = Instance.new( "Camera" ) |
05 | container.Name = "LocalBin" |
06 | container.Parent = Workspace |
09 | local platform = Instance.new( "Part" ) |
10 | platform.CFrame = platform.CFrame * CFrame.new( 23 , 3.5 , - 119.5 ) |
11 | platform.Anchored = true |
12 | platform.Size = Vector 3. new( 2 , 7 , 7 ) |
13 | platform.LeftSurface = "SmoothNoOutlines" |
14 | platform.TopSurface = "SmoothNoOutlines" |
15 | platform.Material = "Slate" |
17 | local StoneSound = Instance.new( "Sound" ) |
18 | StoneSound.Name = "Slateskin" |
21 | StoneSound.Parent = game.Workspace.soundpart |
22 | StoneSound.Looped = false |
25 | platform.Parent = container |
27 | local p = Instance.new( "BoolValue" ,character) |
28 | p.Changed:connect( function () |
29 | game.Workspace.soundpart.Slateskin:Play() |
30 | for i = 3.5 , - 3.8 , - 0.083 do |
32 | container.Part.CFrame = CFrame.new( 23 , i, - 119.5 ) |
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