#why is my remote event not working (somewhat solved)

188 messages · Page 1 of 1 (latest)

mortal moat
#

here is the local script: ```local Button = game.StarterGui.ScreenGui.TextButton
local Player = game.Players.LocalPlayer

Button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.DropName:FireServer(Player)
end)Here is the regular script:game.ReplicatedStorage.DropName.OnServerEvent:Connect(function(Player)
print("Test")
end)```

rapid snow
#

u dont need to pass the player in the fireserver, it already know whos the one who started the event

#

and make sure is everything where it need to be

mortal moat
#

im just trying to print test to see if its passing on

#

but it aint printing

#

when i click the gui button

#

please help

#

why is my remote event not working (still unsolved help)

dawn tinsel
#

If possible, dont use remote events

mortal moat
mossy wraithBOT
#

studio** You are now Level 3! **studio

mortal moat
#

im currently trying to get it to clone first

dawn tinsel
#

Looking at your script, I see that you want to make a button to be clickable

#

Just use a server script, easy as that

mortal moat
#

you mean

#

i can use server script with guis?

dawn tinsel
#

Yea, 100%

mortal moat
dawn tinsel
#

And tbh its better to let the server handle it

dawn tinsel
mortal moat
#

local Player = game.Players.LocalPlayer

#

?

dawn tinsel
#

No... It wont work

#

Depends where your script is located

mortal moat
#

in the button

dawn tinsel
#

LocalPlayer works only on client

mortal moat
#

ive only been scripting for half a week

dawn tinsel
mortal moat
#

it displays a gui

dawn tinsel
dawn tinsel
mortal moat
#

tell me more

dawn tinsel
#

When a player joins, everything inside StarterGui gets cloned and parented to the player's gui (PlayerGui inside the player)

mortal moat
#

i see

dawn tinsel
#

So if we know that, we could get the player if the script is anywhere in the PlayerGui by just getting the first ascensor that is a player class

mortal moat
#

so... if the button is directly in a screen gui script.parent.parent

#

the third parent would be the player?

dawn tinsel
mortal moat
rapid snow
#

i dont think a script in playergui its good.. pretty exploitable

mortal moat
#

its just exploits

rapid snow
#

im not talking to you, im talking to the one is saying that

dawn tinsel
#

But a easy way of getting the player, no matter wher inside of PlayerGui the script is and without having to use .Parent multiple times, is to use FindFirstAncestorOfClass

dawn tinsel
mortal moat
rapid snow
#

yeah but putting that there make it easier lol, just expect your game being hacked for all sides

mortal moat
#

im practasing

dawn tinsel
#

Unless its a competitve game, make your game fun to play and dont fixate on making it un-hackable

mortal moat
#

for my dream game

rapid snow
dawn tinsel
#

He could use the script in ServiceScriptService, that would be safer I guess, but he would have more things to do, if you wanna go thru with him its fine by me, but I wont

mortal moat
#

i will prob use it for something but i dont worry about exploits (i used to be an exploiter shhhh) byfron is here and synapse never gave me my money back and have partnered with rblx soooo

#

i dont worry about exploiters

dawn tinsel
#

Anyways, where were we?

mortal moat
#

ill ping you

dawn tinsel
mortal moat
#

not worth my time and roblox is winning the war agaisnt exploiters

#

did i put the find first ancestor in the correct place?

rapid snow
#

use :

dawn tinsel
#

Like instead of using a RemoteEvent that could be easily exploited, use a server script but dont go the extra mile to make it imposible to cheat. If you are able to make a really fun game, few people would cheat, but if your game is not that fun, way more people would cheat. Lets not even talk about how many people dont even know to write a code and still use cheates that other people made, so if your game is not that big, few people would care to make a cheat

#

local plr = script:FindFirstAncestorOfClass("Player")

rapid snow
#

and do FindFirstAncestorOfClass("Player")

mortal moat
#

now its red

dawn tinsel
#

And dont use the RemoteEvent, that could easily be used by cheaters

rapid snow
#

FindFirstAncestorOfClass("Player")

dawn tinsel
mortal moat
#

although i will use it sometimes

mortal moat
dawn tinsel
#

Line 1

mortal moat
dawn tinsel
#

You are using "StarterGui"

mortal moat
#

until i do smth stupid

dawn tinsel
#

Instead of taking the gui from the player

mortal moat
dawn tinsel
#

First you need to get the player

local plr = script:FindFirstAncestorOfClass("Player")
#

Then you need to find the button

#
local button = plr.PlayerGui.ScreenGui.TextButton
mortal moat
#

local Player = script:FindFirstAncestorOfClass("Player")
local Button = Player.ScreenGui.TextButton

Button.MouseButton1Click:Connect(function()
print("Hewo :3")
end)

#

oh

#

ok

rapid snow
#

or script.Parent no?

dawn tinsel
dawn tinsel
mortal moat
#

local Player = script:FindFirstAncestorOfClass("Player")
local Button = script.Parent

Button.MouseButton1Click:Connect(function()
print("Hewo :3")
end)

dawn tinsel
#

Does it works now?

mortal moat
mossy wraithBOT
#

studio** You are now Level 4! **studio

mortal moat
#

my gift to u

#

i listen to this while scripting

#

now lemme check

mortal moat
#

yup

#

its printing!!!!

dawn tinsel
#

Good

mortal moat
#

ok wait

#

one more thing

#

how do i check what value a player types into a text box so i know how much the player wants to drop

dawn tinsel
#

Now, if you want to make it a bit more secure, you could add the script in ServiceScriptService but you would have to change a few things

dawn tinsel
mortal moat
#

oh

#

remote event

dawn tinsel
mortal moat
#

why is my remote event not working (somewhat solved)

dawn tinsel
#

Some of the things are client sided only, like TextBox, mouse location etc

mortal moat
dawn tinsel
#

And this is where you need a remote event which could be easily used by exploiters

mortal moat
#

i dont have a humanoid?

rapid snow
#

u need to go to char first

#

Player.Character

mortal moat
#

ayyyy

#

im a money machine now

#

although if multible players join does that mean it will also spawn on them?

mortal moat
mortal moat
#

eh

#

thats something for another time

mortal moat
mortal moat
#

i have my lil text box

mortal moat
mortal moat
#

hlep

#

@dawn tinsel

#

local Player = script:FindFirstAncestorOfClass("Player")
local TextBox = script.Parent
local Amount = script.Parent.Amount.Value

if TextBox:IsFocused() == false then
local Amount = TextBox.Text
end

#

how do i fix this mess

#

😭

dawn tinsel
#

Man Im pretty sure IsFocused is a event...

rapid snow
#

do

#

TextBox.FocusLost

#

this gets two parameters

#

the first that is if the enter was pressed and the second that is the inputObject

#

TextBox.FocusLost:Connect(function(enterPressed, inputObject)

Amount = TextBox.Text

end)

#

dont do another local, just change the local u declared

#

you can if u want do only if enterpressed if u want to the value set only if the enter was pressed

#

thats just your likings

mortal moat
#

i dont think the amount is getting changed

#

waiitttt

#

i did smth wrong

mossy wraithBOT
#

studio** You are now Level 5! **studio

mortal moat
#

im tryna to debug this but it just wont work

#

whats wrong with this

mortal moat
rapid snow
#

Amount.Value

#

stop

#

wati a min

#

you need to declare the object of the value

#

local Amount = script.Parent.Amount

#

and then in the textbox you change the value

#

Amount.Value = TextBox.Text

mortal moat
#

oh i see

#

thank you

mortal moat
#
local TextBox = script.Parent
local Amount = script.Parent.Amount

TextBox.FocusLost:Connect(function(enterPressed, inputObject)

        Amount.Value = TextBox.Text
    
end)```
#
local Button = script.Parent
local Money = workspace.Money
local Worth = script.Parent.Parent.TextBox.Amount.Value


Button.MouseButton1Click:Connect(function()
    Worth = script.Parent.Parent.TextBox.Amount.Value
    local position = Player.Character.HumanoidRootPart.Position
    local newObject = Money:Clone()
    newObject.Parent = workspace
    newObject.Position = position
    newObject.Name = "Money"
    newObject.Amount.Value = Worth
end)```
#

what is wrong with me

#

why am i so stupid

mortal moat
rapid snow
#

this needs to be one

mortal moat
#

but then it cant change the value

rapid snow
#

this is where u need to do a remoteevent

mortal moat
#

: (

mortal moat
#

can you teach me how to do remote events? i am just copy pasting em rn having no idea how they work

#

oh.. well i need to go now

#

i will try fix it tommorow

#

thank you for ur help