Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

What is wrong with this script?[Not Answered]

Asked by 10 years ago
a = game.StarterGui.HealthStatus.Frame
b = LocalScript.Parent
function OnTouched (player)
  for Inventory, children in pairs(b:GetChildren()) 
if seatWeld   true then
    a.Visible = true

end




4 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

So many problems here.

Line 01: Every time a player respawns, everything is StarterGui is cloned into PlayerGui. Since you're affecting StarterGui, the GUI won't change until the player respawns. You have to affect a player's PlayerGui for the GUI to change immediately.

Line 02: Both server scripts and local scripts use the same thing to basically mean 'this'. They both use the word, 'script'. It does not change from LocalScripts to ServerScripts. this = 'script'.

Line 03: First off, you never have anything to call the function. That means it will not run. Based off the way you named it, it looks like you want to connect it to the Touched event? If so, the Touched event has the built in parameter 'hit', or the part the hit the brick with the touched event. Not player. However, using this you can get the player with the GetPlayerFromCharacter() method. Also, Touched events should not be run through local scripts.

Line 04 You forgot the do! For loops have to have 'do' after them in order to run. for Inventory, children in pairs(b:GetChildren()) do Also, you never have an end for the for loop.

Line 05: To check if something is true, you have to do one of the following: if bool == true then or, if bool then. On top of that, seatWeld is nil. You never define it in a variable. You also forgot the end for the if statement.

I can't really give you a code answer, because I don't know what you're trying to do. Take a look at the output window, it should help you debug it yourself.

Ad
Log in to vote
1
Answered by
DataStore 530 Moderation Voter
10 years ago

If that's the entire script then there are a number of things wrong with it.

1) Where have you created the 'LocalScript' variable? As it currently stands, in the code you've provided, it's nil (and would error). If you want to get the script's parent, you would just do 'script.Parent'

2) Even if you fix all the errors you're changing the GUI in the StarterGui, rather than the one in the player's PlayerGui. This means that in order for them to see the change they would need to reset.

3) You have a function, but you're not using it anywhere. This means that whatever you're expecting to happen, won't happen.

If you want something to happen when something is touched, as the function's name suggests, you would use the 'Touched' event. For example,

function ARandomFunction(Hit)
    print("I was touched!")
end
script.Parent.Touched:connect(ARandomFunction)

4) You require an end for the function, loop and the if statement. You only currently have one, when you need three.

5) You're missing the 'double equals' (for comparison) on line five, as another user has already pointed out.

6) You've never made a variable called 'seatWeld', so what exactly is 'seatWeld'?

0
Yey for teamwork! Perci1 4988 — 10y
0
seatWeld is when the player sits in the seat it is created ITSolarWinds 25 — 10y
Log in to vote
0
Answered by
RedCombee 585 Moderation Voter
10 years ago

On line 5, it looks like you are looking for:

if seatWeld == true then
0
Didn't work ITSolarWinds 25 — 10y
Log in to vote
-1
Answered by 10 years ago

What part of is that doesn't work?

0
Line 5 ITSolarWinds 25 — 10y

Answer this question