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

The server message button won't work. Anybody know how to improve it?

Asked by 5 years ago

I am making a server message button, but it doesn't seem to work. Anybody know how I can fix this so that it does work? Or any tips?

1function onClicked()
2    local waittime = 5 --Replace with how long you want the message to last
3    local m = Instance.new("Hint")
4    m.Parent = game.Workspace
5    m.Text = "~TEXT~"
6    wait(waittime)
7    m:Destroy()
8 
9end
0
Do you ever call the function? CeramicTile 847 — 5y
0
Did you call the function??? I need more information on what you're trying to do here. JayShepherdMD 147 — 5y
0
Hint is deprecated. With the introduction of Roblox’s GUI features hints have been deprecated and TextLabels should be used instead for new work. The TextLabel object offers a wide range of features for displaying and customizing text that hints do not. User#30567 0 — 5y

3 answers

Log in to vote
1
Answered by 5 years ago
01local clickdetect = Instance.new("ClickDetector") -- Creates the clickdetector
02clickdetect.Parent = script.Parent -- assigns the clickdetector's parent to the part
03if script.Parent:FindFirstChild("ClickDetector") then -- makes sure the clickdetector is inside of the part
04function onClicked(person) -- the function
05    local waittime = 5 --Replace with how long you want the message to last
06    local m = Instance.new("Hint") -- Creates the hint
07    m.Parent = game.Workspace -- assigns the hint's parent to workspace
08    m.Text = (person.Name .." Has Clicked The ".. script.Parent.Name) -- what you want the hint to say
09    wait(waittime) -- how long it takes to destroy the hint, this is changed in 'line 6' of the script
10    m:Destroy() -- destroys the hint
11end
12script.Parent.ClickDetector.MouseClick:Connect(onClicked) -- This is an event, to call the function.
13end

You didn't call the function, and I don't know if you already had clickdetector inside of your part so I just added it for you.

0
FearlessX96, your solution doesn't seem to work. I don't know what I did wrong, but typed exactly what you had. Maybe it has to do with line 8? satrasatra 8 — 5y
0
Nothing wrong with line 8. First, copy and paste the script into your script then drag the script and place it inside the block you want to click. Then test it on Roblox Studio and try clicking the block. FearlessX96 74 — 5y
Ad
Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
5 years ago

Problems that wrong:

You did wrong some problems. Firstly, yep, I think everyone knows, you WASN'T CALL THE FUNCTION.

Second, @TTChaos have already commented at your question, 'Hint' is deprecated and you should use TextLabel.

Third, as important, you need "ClickDetector". That will fire an event called 'MouseClick' when you clicked.

The way to fix the problems:

You must delete the line 3. 'Hint' is deprecated, and enter a "ClickDetector" inside the part. And insert a "TextLabel" into the StarterGui.ScreenGui (You don't need to change any names.)

Script:

01local click = script.Parent.ClickDetector
02 
03function OnClicked(plr)
04    local wait-time = 5
05    local text = game.StarterGui.ScreenGui.TextLabel
06 
07    text.Visible = true
08    text.Text = "~TEXT~"
09    print(plr.Name .. "had clicked the part!")
10    print("Waiting for 5 seconds...")
11    wait(wait-time)
12    print("Done!")
13    text.Visible = false
14end
15 
16click.MouseClick:Connect(OnClicked)

If you have any questions, comment below! I'll be happy to answer them :) If this answer helped you, mark this as the answer! :3 Bye!

0
What do you mean by add a textlabel? If I only add a text label, it won't appear. satrasatra 8 — 5y
0
Go to StarterGui and insert a ScreenGui and put the TextLabel inside, this might work. Xapelize 2658 — 5y
Log in to vote
0
Answered by 5 years ago

I actually figured it out myself, this is the code I used.

1function onClicked()
2    local m = Instance.new("Message")  
3    m.Parent = game.Workspace      
4    m.Text = "Text"        
5    wait(5)
6end
7script.Parent.ClickDetector.MouseClick:connect(onClicked)

Answer this question