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

Why is the Mouse Button 1 Click code/script wont work?

Asked by 4 years ago

I was making a class load out with GUI I have using this script but the Output said that:

****18:18:13.574 - Script 'Players.Kyle_TPD.PlayerGui.ScreenGui.Frame.Confirm.LocalScript', Line 1


Here is the srcipt:

script.Parent.button.MouseButton1Click:Connect(function() local Fire = game.ReplicatedStorage.Weapons Fire:FireServer(script.Parent.Parent.Loadout.Value) script.Parent.Parent:TweenPosition(UDim2.New(2,0,.1,0),"Out","Quad", 1) end)

2
Why are you saving a FireServer in a variable sheepposu 561 — 4y
1
Please put your code in a lua code block so people can understand it better. namespace25 594 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

So here is you original code in a code block so its easier to read a few things that I can see that maybe causing an error is first if a objects name has a space in it you will want to put it in brackets with quotes instead of how you currently have it as the code does not know what you are looking for if there is a space because it thinks that's a different line of code

The second which is more of a question is you are storing an event as a variable while I don't believe there is anything wrong with it that makes no real sense to me or anyone else why its set up like that

Original Code:

script.Parent.button.MouseButton1Click:Connect(function() 
local Fire = game.ReplicatedStorage.Weapons Fire:FireServer(script.Parent.Parent.Loadout.Value) 

script.Parent.Parent:TweenPosition(UDim2.New(2,0,.1,0),"Out","Quad", 1) 
end)

So to make it function you would like your code more like this:

script.Parent.button.MouseButton1Click:Connect(function() 

game.ReplicatedStorage["Weapons Fire"]:FireServer(script.Parent.Parent.Loadout.Value) --change .Weapons Fire --> ["Weapons Fire"]

script.Parent.Parent:TweenPosition(UDim2.New(2,0,0.1,0),"Out","Quad", 1) 
end)

That should allow your code to actually function and fire sorry if the top seemed a bit rude its just I as well as many others where very confused about the layout of your code.

so remember if a part name you are looking for has a space you will need to set up the path to look like this

game.ReplicatedStorage["Weapons Fire"]--to the script this looks like a path

game.ReplicatedStorage.Weapons Fire--to the script this looks like two different lines of code because of the space
0
I hope this works, god bless you! Kyle_TPD 0 — 4y
0
I am unsure if this will make the entire script function as i don't know the explorer layout or what the rest of the code does but at least this could allow for the button to be clicked and fire the server with the information you plan to give it deth836231 142 — 4y
0
wait know line 5 has an error, *facepalm* Kyle_TPD 0 — 4y
0
Maybe because what was selected was not a Frame or a UI element there is also the fact that in the UDmi2.new() there is a .1 deth836231 142 — 4y
Ad

Answer this question