Trying to make a door break script but an error shows up and the obj value dosen't change?
Asked by
6 years ago Edited 6 years ago
I am trying to make a script where you can break doors and walls for a game. But when I click on it there displays an error.
Error: "11:30:47.281 - Players.iiLevelMaker.PlayerGui.ScreenGui.Frame.HealthBG.Bar.LocalScript:10: attempt to index field 'Value' (a nil value)"
Serverscript (Inside Part):
1 | script.Parent.ClickDetector.MouseClick:connect( function (player) |
2 | local obj = script.Parent |
4 | game:GetService( "ReplicatedStorage" ).cutWood:FireClient(player, obj) |
LocalScript (Inside the "Bar" object seen in the error)
1st:
01 | local player = game.Players.LocalPlayer |
02 | local obj = script.Parent.Obj |
04 | script.Parent.Health.Changed:connect( function (player) |
05 | local prog = script.Parent.Health |
07 | script.Parent:TweenSize(UDim 2. new(prog.Value/ 100 , 0 , 1 , 0 ), "In" , "Linear" , . 1 ) |
08 | if prog.Value < = 0 then |
10 | obj.Value.Anchored = false |
2nd Local script:
1 | game:GetService( "ReplicatedStorage" ).cutWood.OnClientEvent:connect( function (player, obj) |
2 | script.Parent.Obj.Value = obj |
3 | script.Parent.Health.Value = script.Parent.Health.Value - 10 |
The health works fine, but the "Obj" value wont change, it's a objectvalue. It's supposed to change to the part the player is hitting.