I don’t see anything wrong there. Can you send the other script also? It might have to do with a modification you made.
I forgot to modify the script that fires the remote event oops but here is the script:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
print("Clicked")
game.ReplicatedStorage.RemoteEvents.RemoteEvent:FireClient(plr,1,1)
print("Worked")
end)
I can’t say I see anything wrong there. Can you double check and see if it works now or if another error is being displayed?
It brings 2 errors one being when the function is first fired which is
attempt to call a nil value
And another one after i click the part which is
Attempt to connect failed: Passed value is not a function
And it also warns when the script runs being
Infinite yield possible on 'Workspace:WaitForChild("Part1")'
Is there anyway that i can fix this?
It has been 22 hours and no one helped me so any help is appreciated
Edit: I didnt realize this was on server and thought it was a gui button
So you mean that i was multiplying an string to the numberValue? And is there anyway to cast the value to object?
I thought you were firing the client, but if you’re getting a infinite yield that means it isnt finding the part
Edit: if yoy could also tell us which errors are from where
I just replaced the script to the one that i mentioned in this topic but im getting an error saying that its unable to cast value to objects which is from this line
game.ReplicatedStorage.RemoteEvents.RemoteEvent:FireClient(1,1)
like i said before, I misunderstood what you were saying, you do pass the player in the first argument of :FireClient(), btw what is the two numbers used for because the function doesnt have any parameters
Well they are used for 2 parameters which are multipliers and Rebirths here is the local script which responds to the remote event when fired for a better understanding:
local plr = game.Players.LocalPlayer
script.Parent.OnClientEvent:Connect(function(multiplied,Rebirths)
if plr.leaderstats.TimeWasted.Value >= (plr.leaderstats.RebirthCost.Value * multiplied) then
plr.leaderstats.Rebirths.Value += Rebirths
game.Workspace.Part1.BillboardGui.TextLabel = "Cost"..plr.leaderstats.RebirthCost.Value.." TimeWasted Points"
end
end
Oh you cant change values on the client btw, it’s a very bad idea since it doesnt replicate, also all checks should be done on the server to ward exploiting.
So what should i do to fix this problem then?
Don’t use a RemoteEvent
if you’re increasing a value, because if it changes from the client then the change would not happen on the server, so I’d recommend you doing this:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
print("Clicked")
local Requirement = plr.leaderstats.RebirthCost.Value * multiplied
if plr.leaderstats.TimeWasted.Value >= Requirement then
print()
plr.leaderstats.Rebirths.Value += Rebirths
end
end)
I want to also make it so the text only changes for the player which i included it from this reply:
Then, do this:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
print("Clicked")
local Requirement = plr.leaderstats.RebirthCost.Value * multiplied
if plr.leaderstats.TimeWasted.Value >= Requirement then
print()
plr.leaderstats.Rebirths.Value += Rebirths
game.ReplicatedStorage.RemoteEvents:FireClient(plr)
end
end)
– Now type this in the local script
gam.ReplicatedStorage.RemoteEvents.RemoteEvent.OnClientEvent:Connect(function()
game.Workspace.Part1.BillboardGui.TextLabel = "Cost"..plr.leaderstats.RebirthCost.Value.." TimeWasted Points"
end)
Hopefully that solves your problem!
The script works but the local script doesn’t work and it doesn’t even give an error
EDIT: Oops i forgot to make it so the rebirthCost increases but it still doesn’t work
Where did you put the local script?
I put the local script in the remote event