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

? Need help placing a mousebutton1click code in a remotefunction code

Asked by 4 years ago

I made a code that puts my username in a string value that I have placed in my startergui and then I made a remote function to basically make a copy of that string value and put it in the workspace and now I want to add a text button so that the remote function will not run until I click on the text button… I've tried a couple times and it will not work with the mousebutton1click method and I do not understand why because when I take out the mousebutton1click code it works perfectly fine... Does anyone know how I could do this?

Localscript :

1local player = game.Players.LocalPlayer
2local val = game.StarterGui.Value
3 
4 
5        val.Value = player.Name.."1"
6 
7        game.ReplicatedStorage.RemoteFunction:InvokeServer(val.Value)

Script :

1game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player,code)   
2local vall = Instance.new("StringValue")
3vall.Parent = workspace
4vall.Value = code
5end

1 answer

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

I assume that your codes are based on StarterGui , which is the wrong way to get the player's gui. Your GUI path should be this:

1--Local Script
2local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
3local Button = PlayerGui. -- Your path
4Button.MouseButton1Click:Connect(function()
5    --Your codes
6end)

I hope this solution helps you. However, due to the limited details, it may not work fine for you.

More Details: PlayerGui.

0
It worked, thank you so much. blox_develop 2 — 4y
0
You may want to accept my answer. ;)) LinavolicaDev 570 — 4y
Ad

Answer this question